﻿using System;
using System.Windows.Controls;

namespace TS3ServerManager.Controls
{
    /// <summary>
    /// Interaction logic for MainAreaControl.xaml
    /// </summary>
    public partial class MainAreaControl
    {
        public MainAreaControl()
        {
            InitializeComponent();
            FunctionalityTabControl.SelectionChanged += FunctionalityTabControlSelectionChanged;
        }

        private void FunctionalityTabControlSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (sender != FunctionalityTabControl || e.RemovedItems.Count == 0 || e.AddedItems.Count == 0)
                return;

            TabItem previousTab = (TabItem) e.RemovedItems[0];
            TabItem currentTab = (TabItem) e.AddedItems[0];

            //if (currentTab == VirtualServersTab)
            //    RefreshVirtualServersTab();
        }

        //private void RefreshVirtualServersTab()
        //{
        //    VirtualServerOverview.Refresh();
        //}

        public void ClearNotifications()
        {
            NotificationsTextBox.Clear();
        }

        public void ShowNotification(string notification)
        {
            RunOnUIThread(() => NotificationsTextBox.AppendText(string.Format("[{0}] {1}\n", DateTime.Now.ToString("hh:mm:ss"), notification.Trim())));
        }
    }
}